#ifndef MODELING_HELPER_H
#define MODELING_HELPER_H

#include <GL/gl.h>

#include "models.h"

class ModelingHelper{

    public:
    
        static Point selectCentroidFace(Face &face){
            Vertex v;
            vector<Edge> &edges = face.getEdges();   
            
            for (int i = 0; i < edges.size(); i++){
                pair<Vertex, Vertex> &vertices = edges[i].getVertices();
                v += vertices.first;
            }
            v /= float(edges.size());
            return Point(v);
        }    
        
        static void drawOrthogonalPlane(Face &face, Scene *scene, Modeling &modeling){
            Point v = selectCentroidFace(face);

            Vertex v1 = face.getEdges()[0].getVertices().first;
            Vertex v2 = face.getEdges()[1].getVertices().first;
            
            Point vector1 = v1 - v;
            Point vector2 = v2 - v;
            
            Point cross = vector1.crossProduct( vector2 ).normalize();
            cross*= 4;
            
            scene->setPlane(Plane(cross, v));
            scene->enablePlane(); 

            modeling.updateScene();
        }
};

#endif /* MODELING_HELPER_H */
